/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import dao.generic.GenericDAOMultiDB;
import java.util.Iterator;
import java.util.List;
import modelo.Sensores;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.criterion.ProjectionList;
import org.hibernate.criterion.Projections;

/**
 *
 * @author Elias Mendoza
 */
public class MultiDAO extends GenericDAOMultiDB {

  public List obtenFecha() {
    List lista = null;
    try {
      iniciarOperacion();
      Query query = sesion.createSQLQuery("select fecha,nd from sensores group by fecha,nd;");

      lista = query.list();

    } finally {
      sesion.close();
    }
    return lista;
  }

  public List prueba() {
    List lista = null;
    try {
      iniciarOperacion();
      Query query = sesion.createSQLQuery("select s1.no_reg,s1.fecha,s1.hora,s1.val_riego,s1.nd ,s1.humedad,s2.humedad,s3.humedad,s4.humedad "
              + " from sa1 as s1,sa2 as s2,sa3 as s3,sa4 as s4"
              + " where s2.no_reg=s1.no_reg and s3.no_reg=s1.no_reg and s4.no_reg=s1.no_reg ");
      lista = query.list();

//      Iterator i = query.list().iterator();
//      while (i.hasNext()) {
//        Object[] array = (Object[]) i.next();
//        for (int in = 0; in < array.length; in++) {
//          System.out.print("," + array[in]);
//        }
//        System.out.println("\n");
//        
//      }


    } finally {
      sesion.close();
    }
    return lista;
  }
}
